import request from '@/utils/request'

// 创建订单
export function createOrder(data) {
  return request({
    url: '/order',
    method: 'post',
    data
  })
}

// 获取用户订单列表
export function getUserOrders(params) {
  return request({
    url: '/order/user',
    method: 'get',
    params
  })
}

// 获取订单详情
export function getOrderDetail(id) {
  return request({
    url: `/order/${id}`,
    method: 'get'
  })
}

// 取消订单
export function cancelOrder(id) {
  return request({
    url: `/order/${id}`,
    method: 'delete'
  })
}

// 确认收货
export function confirmOrder(id) {
  return request({
    url: `/order/${id}/confirm`,
    method: 'post'
  })
}

// 支付订单
export function payOrder(id, paymentMethod) {
  return request({
    url: `/order/${id}/pay`,
    method: 'post',
    data: { paymentMethod }
  })
}

export function updateOrderStatus(orderId, status) {
  return request({
    url: '/order/status',
    method: 'put',
    params: { orderId, status }
  })
}

export function getAllOrders() {
  return request({
    url: '/order/list',
    method: 'get'
  })
} 